package com.springcloud.netflix.eureka.eurekaribbonclient.web;

import com.springcloud.netflix.eureka.eurekaribbonclient.service.ComputeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

@RestController
public class RibbonController {
    @Autowired
    private RestTemplate template;

    @Autowired
    private ComputeService service;

    @GetMapping("info")
    public String info(){
        return "this is ribbon client!";
    }

    @GetMapping("hello")
    public String ribbon(@RequestParam(value = "name",required = false) String name){
        return template.getForObject("http://SERVICE-FEIGN/ribbonhello?name="+name,String.class);
    }

    @GetMapping("hystrix")
    public String testHystrix(){
        return service.testHystrix();
    }

    @GetMapping("feignhello")
    public String hello(String name){
        return "hello "+name+" this is ribbon spring cloud";
    }
}
